pub mod user;
pub mod plan;
pub mod chat;

// 导出 PlanWithUser 结构体
pub use plan::PlanWithUser;

use sqlx::SqlitePool;
use anyhow::Result;

/// 初始化数据库
pub async fn init_database(database_url: &str) -> Result<SqlitePool> {
    let pool = SqlitePool::connect(database_url).await?;
    
    // 执行迁移
    let migration_sql = include_str!("../../migrations/001_init.sql");
    sqlx::raw_sql(migration_sql).execute(&pool).await?;
    
    Ok(pool)
}
